#!/bin/bash


#menu list
menu(){
    echo -e "\e[1:31m 1.install soft\e[0m"
    echo -e "\e[1:31m 2.config python env\e[0m"
    echo -e "\e[1:31m 3.exit\e[0m"
}

#安装软件
install_soft(){
    #装epel源
    yum install epel-release -y
    #安装python3.4版本
    yum install python34 -y
    #安装工具ipython
    yum install ipython -y
    #安装工具python34-pip工具
    yum install python34-pip -y
    #安装语法检测工具
    pip3 install pep8 -y
    #安装flake8语法检测工具，提醒的比pep8更详细
    pip3 install flake8 hacking -y
}

#设置python环境
env_set(){
    cat /etc/vimrc |grep "set ts=4" && echo "the tab=4 already set"
    if (($? != 0));then
    cat >>/etc/vimrc <<EOF

#set tab=4 for python3.4 env
set ts=4
set expandtab
EOF
    source /etc/vimrc &>/dev/null && echo "set table=4 success"
    fi
}

#main function
main(){
    while :
    do
    clear
    menu
    read -p "please input you option:" u_option
    case $u_option in
    1)
    install_soft
    ;;
    2)
    env_set
    ;;
    3)
    exit
    ;;
    *)
    exit
    ;;
    esac
    read 
    done
}
main
